package com.xuecheng.openfeign.sentinel;

import com.xuecheng.common.domain.code.CommonErrorCode;
import com.xuecheng.common.domain.response.RestResponse;
import com.xuecheng.openfeign.Media4Content;
import feign.hystrix.FallbackFactory;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

/**
 * <h4>xuecheng</h4>
 * <p></p>
 *
 * @author : by wujianming
 * @date : 2021-12-16 17:19
 **/
@Component
@Slf4j
public class MediaApiAgentFallBack implements FallbackFactory<Media4Content> {

    @Override
    public Media4Content create(Throwable throwable) {
        return new Media4Content() {
            @Override
            public RestResponse getMediaById(Long mediaId) {
                log.error("查询用户异常", throwable);
                return RestResponse.validfail(CommonErrorCode.E_999981);
//                return null;
            }
        };
    }
}
